/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ScannerParser;

import java.util.*;

/**
 *
 * @author jefoutta
 */
public abstract class Symbol {

    protected String type;
    protected String memoryAddress;
    protected int size;
    protected int width;
    protected int totalWidth;
    protected String name;
    protected int returN;
    protected int correlative;
    protected LinkedList<Symbol> parameters;
    protected String typeSymbol;
    protected String parametersType;
    public boolean alreadyTaken;
    protected int position;
    protected String base;

    public String getName(){
        return this.name;
    }

    public String getFirm(){
        return this.name +this.getParametersType();
    }

    public int getSize(){
        return this.size;
    }

    public int getWidth(){
        return this.width;
    }

    public String getType(){
        return this.type;
    }

    public String getSymbolType(){
        return this.typeSymbol;
    }

    public int getReturn(){
        return this.returN;
    }

    public LinkedList<Symbol> getParameters(){
        return this.parameters;
    }

    public String getParametersType(){
        if(this.typeSymbol.equals("method")){
            this.parametersType = "( ";
            for(int i = 0; i < this.parameters.size(); i++){
                if(this.parameters.get(i).getSize() > 1)
                    this.parametersType = this.parametersType + this.parameters.get(i).getType()+"[] ";
                else
                    this.parametersType = this.parametersType + this.parameters.get(i).getType()+" ";
            }
            this.parametersType = this.parametersType + ")";
            return this.parametersType;
        }else{
            return "";
        }
    }

    public Symbol getLastParameter(){
        return this.parameters.getLast();
    }

    public void addParameter(String tlexema, String ttype, String tsize){
        this.parameters.add(new Variable(tlexema, ttype, tsize, true));
    }
}
